package com.yangguang.huahui.api;

import com.yangguang.huahui.Config;
import com.yangguang.huahui.entity.AttentionList;
import com.yangguang.huahui.entity.HttpResult;
import com.yangguang.huahui.entity.Nongzi;
import com.yangguang.huahui.entity.PublishList;

import okhttp3.ResponseBody;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
import rx.Observable;

/**
 * Created by Administrator on 2017/3/3.
 */

public interface SupplyApi {
    /**
     * 找苗木
     * @param page
     * @return
     */
    @GET(Config.FIND_MIAOMU)
    Observable<AttentionList> getSeedlings(@Query("page") int page, @Query("goods_type") String goods_type, @Query("variety") String variety);

    /**
     * 找花卉
     * @param page
     * @return
     */
    @GET(Config.FIND_FLOWERS)
    Observable<AttentionList> getFlowers(@Query("page") int page);

    /**
     * 找农资
     * @param page
     * @return
     */
    @GET(Config.FIND_NONGZI)
    Observable<Nongzi> getNongzi(@Query("page") int page);

    @GET(Config.FIND_NONGJI)
    Observable<Nongzi> getNongji(@Query("page") int page);

    /**
     * 发布供应
     * @param uid
     * @param variety 品种(页面显示文字 传参就传id)
     * @param goods_specifications 规格(页面显示文字 传参就传id)
     * @param goods_title 商品标题(variety 跟 goods_type 连起来)
     * @param source_of_supply_id 货源地id
     * @param price 价格
     * @param whether_the_spot 是否现货
     * @param time_to_market 上市时间
     * @param expire_date 下市时间
     * @param service_method 服务方式
     * @param carousel 轮播的图片
     * @param contacts 联系人
     * @param phone 联系电话
     * @param supply_mark 供应标识
     * @return
     */
    @FormUrlEncoded
    @POST(Config.PUBLISH_SUPPLY)
    Observable<HttpResult> publish(@Field("uid") String uid, @Field("goods_type") String goods_type, @Field("variety") String variety,
                                   @Field("goods_specifications") String goods_specifications, @Field("goods_title") String goods_title
            , @Field("source_of_supply_id") String source_of_supply_id, @Field("price") String price, @Field("whether_the_spot") String whether_the_spot,
     @Field("time_to_market") String time_to_market, @Field("expire_date") String expire_date,
                                   @Field("service_method") String service_method, @Field("carousel") String carousel, @Field("contacts") String contacts,
                                   @Field("phone") String phone, @Field("supply_mark") String supply_mark, @Field("remarks") String remarks);

    @GET(Config.PUBLISH_SUPPLY_LIST)
    Observable<PublishList> getPublish(@Query("uid") String uid);

    @FormUrlEncoded
    @POST(Config.PUBLISH_SUPPLY_DELETE)
    Observable<PublishList> delete(@Field("id") String id);

    @GET(Config.PUBLISH_SUPPLY_REFRESH)
    Observable<PublishList> refresh(@Query("id") String id, @Query("uid") String uid);
}
